<?php
	include_once "classes/tinchinh_bs.php";
	include_once "classes/baiviet_bs.php";
	include_once "classes/chude_bs.php";
	include_once "classes/chuyenmuc_bs.php";
	include_once "classes/thuvienham.php";
	
	$tinchinh    = new tinchinh_bs();
	$data_tc     = $tinchinh->LayDanhSach();
	
	$baiviet     = new baiviet_bs();
	
	$chude = new chude_bs();
	
	$baivietkhac = new baiviet_bs();
?>

<div id="TinChinh">
	<div id="MotTin">
		<div id="Title">
			<p>NHỮNG TIN CHÍNH</p>
		</div>
		<div id="HinhAnh">
			<?php 
				$baiviet->SetMaBaiViet($data_tc[0]['MaBaiViet']);
				$tmp_baiviet = $baiviet->LayDanhSach();
			?>
			<img width="150px" src="<?php echo $tmp_baiviet[0]['HinhAnh']; ?>" />
		</div>
		<div id="TieuDeVaTomTat">
			<div id="TieuDe">
				<p><?php 
					echo '<a href="index.php?action=baiviet&mbv=' . $tmp_baiviet[0]['MaBaiViet'] . '">' . $tmp_baiviet[0]['TieuDe'] . '</a>';
				?></p>
			</div>
			<div id="TomTat">
				<p><?php 
					echo $tmp_baiviet[0]['TomTat']; 
				?></p>
			</div>
		</div>
	</div>
	<div id="BaTin">
		<div class="TinNho">
			<?php
				$baiviet->SetMaBaiViet($data_tc[1]['MaBaiViet']);
				$tmp_baiviet = $baiviet->LayDanhSach();
			?>
			<div class="HinhTinNho">
				<img src="<?php echo $tmp_baiviet[0]['HinhAnh']; ?>" />
			</div>
			<div class="TieuDe">
				<p><?php 
					echo '<a title="' . $tmp_baiviet[0]['TieuDe'] . '"  href="index.php?action=baiviet&mbv=' . $tmp_baiviet[0]['MaBaiViet'] . '">' . XenChuoi($tmp_baiviet[0]['TieuDe'], 60) . '</a>';
				?></p>
			</div>
		</div>
		<div class="TinNho">
			<div class="HinhTinNho">
				<?php
					$baiviet->SetMaBaiViet($data_tc[2]['MaBaiViet']);
					$tmp_baiviet = $baiviet->LayDanhSach();
				?>
				<img src="<?php echo $tmp_baiviet[0]['HinhAnh']; ?>" />
			</div>
			<div class="TieuDe">
				<p><?php 
					echo '<a title="' . $tmp_baiviet[0]['TieuDe'] . '" href="index.php?action=baiviet&mbv=' . $tmp_baiviet[0]['MaBaiViet'] . '">' .  XenChuoi($tmp_baiviet[0]['TieuDe'], 60) . '</a>';
				?></p>
			</div>
		</div>
		<div class="TinNho">
			<div class="HinhTinNho">
				<?php
					$baiviet->SetMaBaiViet($data_tc[3]['MaBaiViet']);
					$tmp_baiviet = $baiviet->LayDanhSach();
				?>
				<img src="<?php echo $tmp_baiviet[0]['HinhAnh']; ?>" />
			</div>
			<div class="TieuDe">
				<p><?php 
					echo '<a title="' . $tmp_baiviet[0]['TieuDe'] . '"  href="index.php?action=baiviet&mbv=' . $tmp_baiviet[0]['MaBaiViet'] . '">' .  XenChuoi($tmp_baiviet[0]['TieuDe'], 60) . '</a>';
				?></p>
			</div>
		</div>
	</div>
</div>

<?php
	$chude_1 = new chude_bs();
	$data_chude_1 = $chude_1->LayDanhSach();
	for($k = 0; $k < count($data_chude_1); $k++)
	{
		$data_bvk = $baivietkhac->LayBaiVietTheoChuDePhanTrang($data_chude_1[$k]['MaChuDe'], 0, 100);
		if($data_bvk == null)
			continue;
?>

<!--Tin bóng đá Thế giới-->
<div class="TinKhac">
	<div class="Title">
		<div class="ChuDe">
			<a href="index.php?action=baiviet_danhsach&chude=<?php echo $data_chude_1[$k]['MaChuDe'];?>">
				<?php
					$chude->SetMaChuDe($data_chude_1[$k]['MaChuDe']);
					echo $chude->LayTenChuDeTheoMaChuDe();
				?>
			</a>
		</div>	
			<?php
				$chuyenmuc = new chuyenmuc_bs();
				$chuyenmuc->SetMaChuDe($data_chude_1[$k]['MaChuDe']);
				$chuyenmuc_data = $chuyenmuc->LayDanhSach();
				echo '<div class="ChuyenMuc">';
					echo '<ul>';
						for($l = 0; $l < count($chuyenmuc_data); $l++)
							echo '<li><a href="index.php?action=baiviet_danhsach&chude=.' . $chuyenmuc_data[$l]['MaChuyenMuc'] . '">' . $chuyenmuc_data[$l]['TenChuyenMuc'] . '</a></li>';
					echo '<ul>';
				echo '</div>';
			?>
	</div>
	<div class="row1">
		<div class="Tin1">
			<div class="Hinh">
				<img src="<?php echo $data_bvk[0]['HinhAnh']; ?>" />
			</div>
			<div class="TieuDeTomTat">
				<p><?php
					echo "<a title='" . $data_bvk[0]['TieuDe'] . "' href='index.php?action=baiviet&mbv=" . $data_bvk[0]['MaBaiViet'] . "' >" . XenChuoi($data_bvk[0]['TieuDe'], 70) . "</a>";
				?></p>
				<p><?php
					echo XenChuoi($data_bvk[0]['TomTat'], 300);
				?></p>
			</div>
		</div>
	</div>
	<div class="row2">
		<div class="Tin2">
			<div class="TieuDe">
				<p><?php
					echo "<a title='" . $data_bvk[1]['TieuDe'] . "' href='index.php?action=baiviet&mbv=" . $data_bvk[1]['MaBaiViet'] . "' >" . XenChuoi($data_bvk[1]['TieuDe'], 40) . "</a>";
				?></p>
			</div>
			<div class="HinhAnhTomTat">
				<div class="HinhAnh">
					<img src="<?php echo $data_bvk[1]['HinhAnh']; ?>" />
				</div>
				<div class="TomTat">
					<p><?php
						echo XenChuoi($data_bvk[1]['TomTat'], 100);
					?></p>
				</div>
			</div>
		</div>
		<div class="Tin3">
			<div class="TieuDe">
				<p><?php
					echo "<a title='" . $data_bvk[2]['TieuDe'] . "' href='index.php?action=baiviet&mbv=" . $data_bvk[2]['MaBaiViet'] . "' >" . XenChuoi($data_bvk[2]['TieuDe'], 40) . "</a>";
				?></p>
			</div>
			<div class="HinhAnhTomTat">
				<div class="HinhAnh">
					<img src="<?php echo $data_bvk[2]['HinhAnh']; ?>" />
				</div>
				<div class="TomTat">
					<p><?php
						echo XenChuoi($data_bvk[2]['TomTat'], 100);
					?></p>
				</div>
			</div>
		</div>
	</div>
	<div class="row3">
		<p>
			<a title="<?php echo $data_bvk[3]['TieuDe']; ?>" href="<?php echo 'index.php?action=baiviet&mbv='.$data_bvk[3]['MaBaiViet']; ?>"><?php echo XenChuoi($data_bvk[3]['TieuDe'], 70); ?></a>
			<i><?php echo HienThiNgayTheoChuanVietNam($data_bvk[3]['NgayDang']); ?></i>
		</p>
		<p>
			<a title="<?php echo $data_bvk[4]['TieuDe']; ?>" href="<?php echo 'index.php?action=baiviet&mbv='.$data_bvk[4]['MaBaiViet']; ?>"><?php echo XenChuoi($data_bvk[4]['TieuDe'], 70); ?></a>
			<i><?php echo HienThiNgayTheoChuanVietNam($data_bvk[4]['NgayDang']); ?></i>
		</p>
		<p>
			<a title="<?php echo $data_bvk[5]['TieuDe']; ?>" href="<?php echo 'index.php?action=baiviet&mbv='.$data_bvk[5]['MaBaiViet']; ?>"><?php echo XenChuoi($data_bvk[5]['TieuDe'], 70); ?></a>
			<i><?php echo HienThiNgayTheoChuanVietNam($data_bvk[5]['NgayDang']); ?></i>
		</p>
	</div>
</div>

<?php
	}
?>
